<?
include_once("ggheader_new_gly.php");
include_once("/var/www/html/new/d/class/OrderRecord.php");
include_once("/var/www/html/new/d/class/ProductInfo.php");
// $ydle=new yd_go_sql();
// $ydle->connect(); 
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$ordernum=$_REQUEST['ordernum'];
if(!$ordernum){
    header('Location:gtindex.html');
    exit;
}
$orders = array();
$totalMenoey = 0;
if(substr($ordernum,0,2)=='st'){ // 合并的订单
    $sql="select old FROM uu_unitpay WHERE new='$ordernum' and status=0 limit 1";
    $GLOBALS['le']->query($sql);
    $GLOBALS['le']->fetch_assoc();
    $subOrders = $GLOBALS['le']->f('old');
    $subOrders = explode(',', $subOrders);
    foreach($subOrders as $v){
        $or=new OrderRecord($v,$s);
        $order=$or->info();
        $orders[]=$order;
    }
}else{
    $or=new OrderRecord($ordernum,$s);
    $order=$or->info();
    $orders[]=$order;
}
?>
<link type="text/css" rel="stylesheet" href="http://www.12301.cc/shops/css/gorderPay.css" />
<script language="javascript">
$(document).ready(function(){  
    $(".stripe tr:even").addClass("alt"); 
    $(".stripe tr").mouseover(function(){    
        $(this).addClass("over");
    }).mouseout(function(){   
        $(this).removeClass("over");
    }) 
});  
$(function(){
    G.Login.init();
})
</script>
<div class="wrapCon">
	<div class="detail suc">
        <form id="alipay" action="alipayOrder_c.html" method="get" target="_blank">
		    <input type="hidden" id="ordernum" name="ordernum" value="<?=$ordernum?>"/>
        </form>
		<div class="orderpay_nav">
			<span><a href="gcartdetail.html">购物车</a>></span>
			<span class="orderpay_color"><a href="#">支付</a></span>
		</div>
        <div class="PTwrap wrap">
            <div class="container">
                <div class="topDesc">
                    <div class="wareBox">
                        <div class="con">
                            <p class="p1 orange f-18"><i class="icon"></i>订单提交成功，请选择以下支付方式进行支付</p>
                            <p class="p2">注：请于<span class="mrl orangered">2小时</span>内完成支付，逾期订单将失效</p>
                            <div class="ebanks">
                               <dl class="more"> 
                                   <dt>支付平台：</dt>
                                   <dd>
                                       <input id="eb10" type="radio" value="alipay" name="ebank_charge" checked>
                                       <label for="eb10" class="Alipay" title="支付宝"></label>
                                   </dd>
                              </dl>
                            </div>
                        </div>
                    </div>
                </div>
                <?if(substr($ordernum,0,2)=='st'):?>
                <button> </button>
                <?else:?>
                <button id="submitBtn" type="submit" class="submitBtn_3">确认无误，去支付</button>
                <?endif;?>
                <!-- 弹出层模块BOF -->
                <div id="PayDialog">
                    <p class="tip"><i>&nbsp;</i>付款完成前请勿关闭当前窗口，完成付款后请根据你的情况点击下面按钮。</p>
                    <strong>请在支付页完成付款后再选择：</strong>
                    <div class="pay">
                        <input type="button" class="success" id="PaySuccess" value="已完成付款"/>
                        <input type="button" class="close" value="付款出现问题" />
                    </div>
                    <br/>
                    <a href="javascript:" class="close">&lt;&lt;返回重新选择付款方式</a>
                </div>
				<!--弹出结束-->
              <div class="tick_table" >
				<div class="sure_order"></div>
				<div class="kuang_table">
				   <table width="850" border="0" class="stripe" cellpadding="0" cellspacing="1">
						<tr class="title_td">
							<th width="80">订单号</th>
							<th width="100">数量</th>
							<th width="50">金额</th>
							<th width="150">使用时间</th>
							<th width="50">联系人</th>
							<th width="50">手机号</th>
						</tr>
                        <?foreach($orders as $order):?>
                        <?
                            $totalMenoey += $order['mainOrder']->UUtnum*$order['mainOrder']->UUtprice;
                        ?>
						<tr class="title_tr">
							<td width="80" ><?=$order['mainOrder']->UUordernum?></td>
							<td width="100"><?=$order['mainOrder']->UUtnum?></td>
							<td width="50" ><?=($order['mainOrder']->UUtnum*$order['mainOrder']->UUtprice)/100?></td>
							<td width="150"><?=$order['mainOrder']->UUbegintime?></td>
							<td width="50" ><?=$order['mainOrder']->UUordername?></td>
							<td width="50" ><?=$order['mainOrder']->UUordertel?></td>
						</tr>
                        <?if($order['childOrder']):?>
                            <?foreach($order['childOrder'] as $cr):?>
                            <?
                                $totalMenoey +=$cr->UUtnum*$cr->UUtprice;
                            ?>
                            <tr class="title_tr">
                                <td width="80" ><?=$cr->UUordernum?></td>
                                <td width="100"><?=$cr->UUtnum?></td>
                                <td width="50" ><?=($cr->UUtnum*$cr->UUtprice)/100?></td>
                                <td width="150"><?=$cr->UUbegintime?></td>
                                <td width="50" ><?=$cr->UUordername?></td>
                                <td width="50" ><?=$cr->UUordertel?></td>
                            </tr>
                            <?endforeach;?>
                        <?endif;?>
                        <?endforeach;?>
					</table>
				</div>
                <div class="totalPay">应付金额：<span class="orange">¥<?=$totalMenoey/100?></span></div>
            </div>
        </div>
	</div>
</div>
</div>

<script src="http://www.12301.cc/js/easydialog.min.js"></script>
<script>
jQuery(document).ready(function($) {
    var orderid = $("input[name='ordernum']").val(),payResult= 0,interval_id=0;
    var obj_funcs = {
        closeDialog:function() {
            easyDialog.close();
        },
        toPageSucess:function() {
            location.href="gmem.html";
        },
        checkPayState:function(){
            $.get('call/jh_client.php',{action:'CheckOrderPay',orderid:orderid},function(res){
                if(res==1){
                    payResult = 1;
                    clearInterval(interval_id);
                }
            });
        },
        chk:function(){
            setTimeout(this.checkPayState,1000);
        }

    };
    $(".ebanks dd *").click(function(){
        var gateid=$(this).attr("gateid");
        $("#Bankco").val(gateid);
        $(".ebanks dd input").each(function(){
            $(this).attr("checked",false)
        });
        var input=$(this).parent().children().first()
        input.attr("checked",true);
    });
    $("#submitBtn").click(function(){
        var ebank_charge = $("input[name='ebank_charge']:checked").val(),
            submitTo;
        if(!ebank_charge){
            alert("请选择支付方式");
            return false;
        }
        else if(ebank_charge==='alipay') {
            submitTo = 'alipay';
        }
        else {
            submitTo = 'alipay';
        }
        $("form#"+submitTo).submit();
        easyDialog.open({
            container : 'PayDialog',
            fixed : false
        });
        setTimeout(function(){
            interval_id = setInterval(obj_funcs.checkPayState, 2000);
        },20000);
    });
    $(".close").bind('click',function(){
        clearInterval(interval_id);
        obj_funcs.closeDialog();
    });
    $("#PaySuccess").bind('click',function(){
        if(payResult) {
            clearInterval(interval_id);
            obj_funcs.toPageSucess();
        } else {
            alert('您还未支付成功，请在支付成功后点击该按钮');
            return false;
        }
    });
});
</script>
<?php include_once("ggfoot_m.php");?>